package com.kede.api.stand.config;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/***
 ** @Author:Pr.li
 ** @Description:
 ** @Date: create in 2023/4/27 9:28
 ***/
@Data
@Configuration
@EnableWebMvc
public class WebMvcConfig implements WebMvcConfigurer {

    /**
     * 存放文件的地址
     */
    @Value("${file.location}")
    private String location;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        String filepath = "file:" + location.replace("\\","/");
        registry.addResourceHandler("/file/**").addResourceLocations(filepath).setCachePeriod(0);
    }
}
